/**
 * 使用递归计算1*2 + 2*3 + 3*4 + (n-1)*n
 * 1 * 2 +  2 * 3
 */
function calc(num) {
    if (num == 2) {
        return 2;
    } else {
        return calc(num - 1) + (num - 1) * num;
    }
}

console.log(calc(3));